﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:UI="clr-namespace:TraceView.UI"
                    xmlns:CustomControls="clr-namespace:TraceView.UI.CustomControls">
   

    <ControlTemplate
                x:Key="ChromeButtonControlTemplate"
                TargetType="{x:Type ButtonBase}">
        <Border
                    x:Name="Chrome"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    Margin="0"
                    Background="{TemplateBinding Background}"
                    SnapsToDevicePixels="True">
            <ContentPresenter
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        Content="{TemplateBinding Content}"
                        ContentStringFormat="{TemplateBinding ContentStringFormat}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        Margin="{TemplateBinding Padding}"
                        RecognizesAccessKey="True"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
        </Border>
        <ControlTemplate.Triggers>
            <Trigger
                        Property="IsEnabled"
                        Value="False">
                <Setter
                            Property="Foreground"
                            Value="#FFADADAD" />
                <Setter
                            Property="Opacity"
                            TargetName="Chrome"
                            Value="0.5" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    <Style x:Key="ChromeButtonStyle"
           TargetType="{x:Type Button}">
        <Style.Resources>
            <Storyboard
                        x:Key="OnMouseDownStoryboard">
                <DoubleAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Opacity)"
                            Storyboard.TargetName="{x:Null}">
                    <EasingDoubleKeyFrame
                                KeyTime="0"
                                Value="0.5" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard
                        x:Key="OnMouseUpStoryboard">
                <DoubleAnimationUsingKeyFrames
                            Storyboard.TargetProperty="(UIElement.Opacity)"
                            Storyboard.TargetName="{x:Null}">
                    <EasingDoubleKeyFrame
                                KeyTime="0"
                                Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </Style.Resources>
        <Setter
                    Property="Background"
                    Value="#00000000" />
        <Setter
                    Property="BorderBrush"
                    Value="{x:Null}" />
        <Setter
                    Property="BorderThickness"
                    Value="0" />
        <Setter
                    Property="Padding"
                    Value="0" />
        <Setter
                    Property="Cursor"
                    Value="Hand" />
        <Setter
                    Property="Template"
                    Value="{StaticResource ChromeButtonControlTemplate}" />
        <Style.Triggers>
            <Trigger
                        Property="IsEnabled"
                        Value="False">
                <Setter
                            Property="Opacity"
                            Value="0.5" />
            </Trigger>
            <EventTrigger
                        RoutedEvent="Mouse.PreviewMouseDown">
                <BeginStoryboard
                            x:Name="OnMouseDown_BeginStoryboard"
                            Storyboard="{StaticResource OnMouseDownStoryboard}" />
            </EventTrigger>
            <EventTrigger
                        RoutedEvent="Mouse.PreviewMouseUp">
                <BeginStoryboard
                            x:Name="OnMouseUp_BeginStoryboard"
                            Storyboard="{StaticResource OnMouseUpStoryboard}" />
            </EventTrigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="FontFamily" Value="Segoe UI"/>
    </Style>
    
    <Style TargetType="{x:Type Button}">
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="FontWeight" Value="Regular"/>
        <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>
        <Setter Property="Margin" Value="5,5,5,5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      Margin="{TemplateBinding Padding}"
                                      x:Name="Content"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="FontWeight" Value="DemiBold"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                <Setter Property="FontWeight" Value="DemiBold"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="TabRepeatButtonStyle" TargetType="{x:Type RepeatButton}">        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          x:Name="Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>      
    </Style>
    
    <Style x:Key="TabApplicationHeaders" TargetType="{x:Type TabControl}">
        <Setter Property="Margin" Value="5,5,5,5"/>
        <Setter Property="FontWeight" Value="UltraLight"/>       
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border BorderBrush="{StaticResource BorderHorizontalRightSeperator}"
                                BorderThickness="0,0,0,0.5">
                        <Grid> 
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <RepeatButton x:Name="cmdScrollLeft"
                                          Focusable="False"    
                                          Margin="10,2,10,2"
                                          Width="20"
                                          Height="20"                                       
                                          BorderThickness="0"
                                          Style="{StaticResource TabRepeatButtonStyle}"
                                          VerticalAlignment="Center"
                                          CommandTarget="{Binding ElementName=svTP}"
                                          Command="ScrollBar.LineLeftCommand"
                                          Visibility="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollLeft, Converter={UI:BoolToVisibilityConverter TrueMapsTo=Visible,FalseMapsTo=Collapsed}}"
                                          IsEnabled="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollLeft}">                                
                                <Image Source="{StaticResource Back}"
                                       Width="18"
                                       Height="18"/>
                            </RepeatButton>                                           
                            <ScrollViewer VerticalScrollBarVisibility="Disabled"
                                          CanContentScroll="True" 
                                          HorizontalScrollBarVisibility="Hidden"
                                          IsDeferredScrollingEnabled="False"
                                          SnapsToDevicePixels="True"
                                          BorderThickness="0"
                                          Padding="0"
                                          Name="svTP"
                                          Grid.Column="1" 
                                          Height="55"                                         
                                          HorizontalAlignment="Stretch" 
                                          VerticalAlignment="Stretch">
                                <CustomControls:ScrollableTabPanel IsItemsHost="True"
                                                        x:Name="PART_ScrollContentPresenter"                                                                                                                                                          
                                                        RightOverflowMargin="4"  
                                                        AnimationTimeSpan="0:0:0.25" 
                                                        LineScrollPixelCount="100"                                                                                                                                                                                                                                     
                                                        KeyboardNavigation.TabIndex="1"/>
                            </ScrollViewer>
                            <RepeatButton x:Name="cmdScrollRight"
                                          Focusable="False" 
                                          Grid.Column="2"  
                                          Margin="10,2,10,2"
                                          Width="20"
                                          Height="20"                                        
                                          BorderThickness="0"
                                          Style="{StaticResource TabRepeatButtonStyle}"
                                          VerticalAlignment="Center"
                                          CommandTarget="{Binding ElementName=svTP}"
                                          Command="ScrollBar.LineRightCommand" 
                                          Visibility="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollRight, Converter={UI:BoolToVisibilityConverter TrueMapsTo=Visible,FalseMapsTo=Collapsed}}"
                                          IsEnabled="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollRight}">
                                <Image Source="{StaticResource Next}"
                                       Width="18"
                                       Height="18"/>
                            </RepeatButton>
                        </Grid>
                        </Border>
                        <Border x:Name="Border" 
                                        BorderThickness="0,0,0,0" 
                                        BorderBrush="{StaticResource MetroWhite}" 
                                        Margin="5,0,5,5"
                                        Grid.Row="1" 
                                        KeyboardNavigation.DirectionalNavigation="Contained" 
                                        KeyboardNavigation.TabIndex="2" 
                                        KeyboardNavigation.TabNavigation="Local" 
                                        Padding="5">
                            <ContentPresenter x:Name="PART_SelectedContentHost" 
                                                      Content="{TemplateBinding SelectedContent}" 
                                                      ContentSource="SelectedContent" 
                                                      VerticalAlignment="Top"
                                                      ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                                                      ContentTemplate="{TemplateBinding SelectedContentTemplate}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                            <Setter Property="Background" Value="Transparent"/>
                            <Setter Property="BorderBrush" TargetName="Border" Value="Gray"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="FontWeight" Value="ExtraLight"/>        
        <Setter Property="FontFamily" Value="Segoe UI"/>        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}" >
                    <AdornerDecorator VerticalAlignment="Bottom">
                        <Grid x:Name="MainGrid" 
                              Margin="0,0,0,0"
                              VerticalAlignment="Bottom">
                            <Border x:Name="border" VerticalAlignment="Bottom">
                                <Grid Width="Auto" Height="Auto" VerticalAlignment="Bottom">  
                                    <TextBlock FontSize="35">
                                    <ContentPresenter x:Name="ContentSite"
                                                      RecognizesAccessKey="True"                                                      
                                                      ContentSource="Header"  
                                                      Margin="8,2,8,2"/>
                                    </TextBlock>
                                </Grid>
                            </Border>
                        </Grid>
                    </AdornerDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Selector.IsSelected" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>                           
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="DarkGray" />
                            <Setter Property="Background" Value="Transparent" TargetName="border"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="WhiteSmoke"/>                          
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>       
        <Style.Triggers>
            <Trigger Property="Selector.IsSelected" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>                                   
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelected" Value="False" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>                                 
                <Setter Property="Cursor" Value="Hand"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type RadioButton}">
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="FontWeight" Value="ExtraLight"/>
        <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>
        <Setter Property="Margin" Value="5,5,5,5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      Margin="{TemplateBinding Padding}"
                                      x:Name="Content"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="FontWeight" Value="DemiBold"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                <Setter Property="FontWeight" Value="DemiBold"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="FontWeight" Value="Light"/>
        <Setter Property="Margin" Value="5,5,5,5"/>
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          x:Name="Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                <Setter Property="Cursor" Value="Hand"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="ToggleExpander" TargetType="{x:Type ToggleButton}">
        <Setter Property="FontWeight" Value="Light"/>
        <Setter Property="Margin" Value="5,5,5,5"/>
        <Setter Property="FontFamily" Value="Segoe UI"/>
        <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          Margin="{TemplateBinding Padding}"
                                          x:Name="Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">               
                <Setter Property="Cursor" Value="Hand"/>
            </Trigger>          
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type Thumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid Margin="0,0,0,0" x:Name="Grid">
                        <Rectangle HorizontalAlignment="Stretch"
                                   x:Name="Rectangle"
                                   VerticalAlignment="Stretch"                                   
                                   Width="Auto"
                                   Height="Auto"
                                   RadiusX="3"
                                   RadiusY="3"
                                   Stroke="Transparent"
                                   Fill="Gray" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True" />
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="Rectangle" Value="LightGray" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False" />
                        <Trigger Property="IsDragging" Value="True" />
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="RepeatButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Rectangle Fill="Transparent"
                                           Stroke="Transparent"
                                           StrokeThickness="0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="GridRoot"   
                                  Background="Transparent"                                  
                                  Width="10">
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="10" />
                            <RowDefinition Height="0.00001*" />
                            <RowDefinition MaxHeight="10" />
                        </Grid.RowDefinitions>
                        <Track Grid.Row="1"
                                       x:Name="PART_Track"
                                       Orientation="Vertical"                                          
                                       IsDirectionReversed="true">
                            <Track.Thumb>
                                <Thumb  />
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type ScrollViewer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter Grid.Column="0"
                                                Grid.Row="0"                                                 
                                                Margin="{TemplateBinding Padding}"
                                                Content="{TemplateBinding Content}"  
                                                ClipToBounds="True"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                CanContentScroll="{TemplateBinding CanContentScroll}" />
                        <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                   Grid.Column="0"
                                   Grid.Row="1"
                                   x:Name="PART_HorizontalScrollBar"
                                   Orientation="Horizontal"
                                   Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                   ViewportSize="{TemplateBinding ViewportWidth}"
                                   Minimum="0"
                                           BorderThickness="0"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   AutomationProperties.AutomationId="HorizontalScrollBar" />
                        <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                   Grid.Column="1"
                                   Grid.Row="0"
                                   x:Name="PART_VerticalScrollBar"
                                   Orientation="Vertical"
                                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   Minimum="0"
                                            BorderThickness="0"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   AutomationProperties.AutomationId="VerticalScrollBar" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="0"/>
    </Style>   
    
    <Style TargetType="{x:Type ListBoxItem}">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                                 Color="Transparent"/>
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
                                 Color="Transparent"/>
        </Style.Resources>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource MetroWhite}"/>
        <!--<Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="Orange"/>
            </Trigger>
        </Style.Triggers>-->
    </Style>   
    
    <Style TargetType="{x:Type Expander}">       
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontWeight" Value="Thin"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <AdornerDecorator>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" x:Name="ContentRow" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0"
                                    x:Name="Border"
                                    Margin="0,0,0,0"
                                    BorderThickness="0,0,0,.3"                                   
                                    BorderBrush="{StaticResource toggleBtnBrush}">
                                <Grid>
                                    <Grid.ColumnDefinitions>                                        
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Border BorderThickness=".3,.3,.3,0" BorderBrush="{StaticResource toggleBtnBrush}">                                        
                                    <Border x:Name="brToggleHeader"
                                            Opacity="0"   
                                            Background="{StaticResource toggleBtnBrush}"                                           
                                            Margin="0,0,0,0">                                                                          
                                    </Border>
                                    </Border>
                                    <ToggleButton IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                                  Margin="0,2,0,0"
                                                  Style="{StaticResource ToggleExpander}"
                                                  x:Name="ToggleHeader"                                                  
                                                  FontSize="16"                                                      
                                                  OverridesDefaultStyle="True" >                                                                               
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="24"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Text="+" 
                                                           Name="ExpandText" 
                                                           HorizontalAlignment="Left" 
                                                           VerticalAlignment="Center" 
                                                           FontSize="14"
                                                           Padding="2,2,2,2"
                                                           FontWeight="Bold"                                                          
                                                           Foreground="{StaticResource SelectedControlText}"/>
                                                <TextBlock Text="-" 
                                                           Name="CollapseText"
                                                           Visibility="Collapsed" 
                                                           HorizontalAlignment="Left" 
                                                           VerticalAlignment="Center" 
                                                           FontSize="14"
                                                           Padding="2,2,4,2"
                                                           FontWeight="Bold"                                                          
                                                           Foreground="{StaticResource SelectedControlText}"/>
                                                <ContentPresenter Grid.Column="1"  
                                                                  Margin="5,2,20,2"
                                                                  RecognizesAccessKey="True"
                                                                  ContentSource="Header" />
                                            </Grid>                                                                                                              
                                    </ToggleButton>
                                </Grid>
                            </Border>
                            <Border Visibility="Collapsed"
                                    Grid.Row="1"
                                    Margin="5,0,5,5"
                                    x:Name="ExpandSite"
                                    Background="Transparent"
                                    BorderBrush="Transparent"
                                    BorderThickness="0">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="0"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  Focusable="false" />
                            </Border>
                        </Grid>
                    </AdornerDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter Property="Visibility" Value="Visible" TargetName="ExpandSite" />
                            <Setter Property="Visibility" Value="Visible" TargetName="CollapseText" />
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ExpandText" />
                            <Setter Property="Opacity" TargetName="brToggleHeader" Value="1"/>
                            <Setter Property="FontWeight" TargetName="ToggleHeader" Value="SemiBold"/>
                        </Trigger>                        
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Opacity" TargetName="brToggleHeader" Value="1"/>
                            <Setter Property="FontWeight" TargetName="ToggleHeader" Value="SemiBold"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="Gray" TargetName="Border" />
                            <Setter Property="BorderBrush" Value="Gray" TargetName="Border" />
                            <Setter Property="Foreground" Value="DarkGray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>  
    
    <Style TargetType="{x:Type CustomControls:ImageButton}">
        <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type CustomControls:ImageButton}">
                <Grid>
                    <Image x:Name="Image1" Source="{TemplateBinding DefaultImageSource}"
                            UseLayoutRounding="True"/>
                    <Image x:Name="Image2" Source="{TemplateBinding MouseOverImageSource}"
                           Visibility="Collapsed"
                            UseLayoutRounding="True"/>
                </Grid>                        
                <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type CustomControls:ImageRadioButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomControls:ImageRadioButton}">
                    <Grid>
                        <Image x:Name="Image1" Source="{TemplateBinding DefaultImageSource}"
                            UseLayoutRounding="True"/>
                        <Image x:Name="Image2" Source="{TemplateBinding MouseOverImageSource}"
                           Visibility="Collapsed"
                            UseLayoutRounding="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NumberImageRadioButton" TargetType="{x:Type CustomControls:ImageRadioButton}">
        <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomControls:ImageRadioButton}">
                    <Grid>
                        <Image x:Name="Image1" Source="{TemplateBinding DefaultImageSource}"
                            UseLayoutRounding="True"/>
                        <Image x:Name="Image2" Source="{TemplateBinding MouseOverImageSource}"
                           Visibility="Collapsed"
                            UseLayoutRounding="True"/>
                        <ContentPresenter  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Image1" Property="Visibility" Value="Collapsed"/>
                            <Setter Property="Foreground" Value="{StaticResource MetroWhite}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Image1" Property="Visibility" Value="Collapsed"/>
                            <Setter Property="Foreground" Value="{StaticResource MetroWhite}"/>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ThemeImageRadioButton" TargetType="{x:Type CustomControls:ImageRadioButton}">       
        <Setter Property="Template">
            
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomControls:ImageRadioButton}">
                    <Border BorderBrush="{StaticResource MetroWhite}"
                            Padding="5"
                            Width="90"
                            Height="90"
                            x:Name="SelectedBorder"
                            BorderThickness="0">
                    <Border x:Name="ImageBorder"                             
                            Width="80"
                            Height="80"
                            BorderThickness=".6"
                            BorderBrush="{StaticResource MetroGray}">
                     <Grid>
                            <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0"/>
                        </Grid>
                    </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">                            
                            <Setter Property="Opacity" TargetName="ImageBorder" Value="1"/>                           
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Opacity" TargetName="ImageBorder" Value="1"/>                           
                            <Setter Property="Width" TargetName="ImageBorder" Value="80"/>
                            <Setter Property="Height" TargetName="ImageBorder" Value="80"/>
                            <Setter Property="BorderThickness" TargetName="SelectedBorder" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type CustomControls:ImageToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomControls:ImageToggleButton}">
                    <Grid>
                        <Image x:Name="Image1" Source="{TemplateBinding DefaultImageSource}"
                            UseLayoutRounding="True"/>
                        <Image x:Name="Image2" Source="{TemplateBinding MouseOverImageSource}"
                           Visibility="Collapsed"
                            UseLayoutRounding="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>                        
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Image2" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Image1" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="Foreground" Value="{StaticResource MetroGray}"/>
        <Setter Property="FontWeight" Value="ExtraLight"/>
        <Setter Property="FontSize" Value="16"/>
        <Setter Property="Margin" Value="4"/>
         <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">                                           
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <ContentPresenter Content="{TemplateBinding Content}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      Margin="{TemplateBinding Padding}"
                                      HorizontalAlignment="{TemplateBinding 
                                      HorizontalContentAlignment}"
                                          Grid.Column="1"
                                      VerticalAlignment="{TemplateBinding
                                      VerticalContentAlignment}" />
                        <Border Width="15" 
                                Height="15" 
                                x:Name="CheckIndicator"
                                BorderBrush="{StaticResource MetroGray}"
                                BorderThickness=".6">
                            <Border.Background>
                                <VisualBrush >
                                    <VisualBrush.Visual>
                                        <Image Name="image"
                                           Width="12"
                                           Height="12"
                                           />
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </Border.Background>
                        </Border>                        
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="image"
                            Property="Source"
                            Value="{StaticResource CheckW}" />
                            <Setter Property="BorderBrush" TargetName="CheckIndicator" Value="{StaticResource MetroWhite}"/>
                            <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" TargetName="CheckIndicator" Value="{StaticResource MetroWhite}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>               
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="FontWeight" Value="Normal"/>              
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="FontWeight" Value="Normal"/>
                <Setter Property="Foreground" Value="{StaticResource SelectedControlText}"/>
            </Trigger>            
        </Style.Triggers>
</Style>

    <Style x:Key="ColourPickerButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type CustomControls:ColourSlider}">
        <Setter Property="Orientation" Value="Vertical"/>
        <Setter Property="IsMoveToPointEnabled" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CustomControls:ColourSlider}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="80"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" MinWidth="25"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0" 
                                Height="{TemplateBinding Slider.Height}" 
                                MinHeight="80"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <Border Margin="0" Background="{TemplateBinding Background}" />
                        </Border>
                        <Track Grid.Column="0" Name="PART_Track">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton Style="{StaticResource ColourPickerButtonStyle}"
                                  Command="Slider.DecreaseLarge" />
                            </Track.DecreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb>
                                    <Thumb.Template>
                                        <ControlTemplate>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="10" />
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="10" />
                                                </Grid.ColumnDefinitions>
                                                <Image Grid.Column="0" Width="10">
                                                    <Image.Source>
                                                        <DrawingImage>
                                                            <DrawingImage.Drawing>
                                                                <GeometryDrawing Geometry="M0,0 L1,0.5 0,1Z">
                                                                    <GeometryDrawing.Pen>
                                                                        <Pen Brush="{StaticResource MetroWhite}"/>
                                                                    </GeometryDrawing.Pen>
                                                                </GeometryDrawing>
                                                            </DrawingImage.Drawing>
                                                        </DrawingImage>
                                                    </Image.Source>
                                                </Image>
                                            </Grid>
                                        </ControlTemplate>
                                    </Thumb.Template>
                                </Thumb>
                            </Track.Thumb>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton 
                                  Style="{StaticResource ColourPickerButtonStyle}"
                                  Command="Slider.IncreaseLarge" />
                            </Track.IncreaseRepeatButton>
                        </Track>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>